package ejb;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.Query;

import dao.BaseDao;
import entity.Students;

@Stateless
public class StudentsBean extends BaseDao<Students> implements StudentsBeanRemote, StudentsBeanLocal {
	
	@SuppressWarnings("unchecked")
	@Override
	public List<Students> getAll() {
		Query query = this.em.createNamedQuery("Students.findAll");
		return query.getResultList();
	}
	
	@Override
	public Students getByStudentId(String studentId) {
		try {
			Query query = em.createNamedQuery("Students.getByStudentId");
			query.setParameter("studentId", studentId);
			return (Students) query.getSingleResult();
        } catch (Exception e) {
            return null;
        }
	}
}
